﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using GGEditor.API;
using GGEditor.API.Plugins;

namespace GGEditor.Core
{
	[XmlNodeObjectFactory(Name = "Node")]
	public class NodeFactory : IXmlNodeObjectFactory
	{
		#region Implementation of IXmlNodeObjectFactory

		public virtual object Build(IPluginNode pluginNode, IDictionary<string, string> attributes)
		{
			return ObjectCreator.Create(pluginNode.Plugin.Assemblies, attributes["type"]);
		}

		#endregion
	}

	public class NodeFactory<T> : IXmlNodeObjectFactory where T : class
	{
		#region Implementation of IXmlNodeObjectFactory

		public virtual object Build(IPluginNode pluginNode, IDictionary<string, string> attributes)
		{
			return ObjectCreator.Create<T>(pluginNode.Plugin.Assemblies, attributes["type"]);
		}

		#endregion
	}
}
